package com.asset.dispoal.extension.strategy.command;

import com.asset.dispoal.extension.domain.dto.RolePermissionDTO;
import com.asset.dispoal.extension.strategy.BaseDataPowerStrategyServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerParam;
import tech.mhuang.pacebox.core.strategy.StrategyHandlerResult;

import java.util.Collections;
import java.util.List;

/**
 * 自定义人
 *
 * @author mhuang
 * @since 1.0.0
 */
@Component
@Slf4j
public class CustomPersonDataPowerStrategyServer implements BaseDataPowerStrategyServer {

    @Override
    public StrategyHandlerResult<String> strategy(StrategyHandlerParam<RolePermissionDTO> strategyHandlerParam) {
        RolePermissionDTO dto = strategyHandlerParam.getData();
        String sqlHeader = "SELECT 1 FROM sys_role_auth_user power " +
                " where power.role_id = '" + dto.getRoleId() + "'" +
                " and power.user_id =" + dto.getCarry();
        return new StrategyHandlerResult<>(true, sqlHeader);
    }

    @Override
    public List<String> event() {
        return Collections.singletonList("1");
    }
}
